package com.ai.bitcoin.jpa.dao;

import com.ai.bitcoin.jpa.entity.CoinNews2Bcc;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

/**
 * @description: ${description}
 * @author: gulj
 * @create: 2018-08-02 22:18
 **/
public interface CoinNews2BccDao extends JpaRepository<CoinNews2Bcc, String> {


    @Query(nativeQuery = true, value = "SELECT * FROM coin_news2bcc where bcc_id = ?1 ORDER BY update_time desc limit 3")
    List<CoinNews2Bcc> getTop3ByBccId(String bccId);

    //时间范围内币消息
    List<CoinNews2Bcc> findByUpdateTimeIsBetween(Date startDate, Date endDate);

    @Query("SELECT e FROM CoinNews2Bcc e WHERE e.synced = false ")
//    @Query("SELECT e FROM CoinNews2Bcc e WHERE e.synced = false ")
    Page<CoinNews2Bcc> findAllNews(Pageable pageable);
}
